package com.michael.retail.sys.biz.service.impl;

import com.michael.retail.sys.api.pojo.entity.SysUser;
import com.michael.retail.sys.biz.service.SysUserService;
import org.springframework.stereotype.Service;

import java.util.Arrays;

/**
 * 类功能描述:
 * <pre>
 *   SysUserService
 * </pre>
 *
 * @author Michael
 * @version 1.0
 * @date 2021/7/6 16:46
 */
@Service
public class SysUserServiceImpl implements SysUserService {

    private SysUser userAbc() {
        return new SysUser(
                1L,
                "abc",
                "$2a$10$WQEprKVosDQ2WEu2pmivQ.5D4So5luotURQgJVj35Wi7jRdM0XuR2",
                "abc",
                "13800138000",
                1,
                "abc@abc.com",
                0,
                Arrays.asList("aaa", "bbb", "ccc")
        );
    }

    private SysUser user123() {
        return new SysUser(
                2L,
                "123",
                "$2a$10$./oBpdma8TkQ9c3/H7QdE.nHj82UvotKtgoa7KKn7nT03PhlUNkpi",
                "123",
                "13800138000",
                1,
                "123@123.com",
                1,
                Arrays.asList("111", "222", "333")
        );
    }

    private SysUser userMichael() {
        return new SysUser(
                3L,
                "michael",
                "$2a$10$9BJR70Z4SU9l1A4tMDbsBew2iTY0UPuxKQjcdOo7NX2Cpch6cx1/W",
                "michael",
                "13800138000",
                1,
                "michael@michael.com",
                0,
                Arrays.asList("111", "aaa", "bbb", "333")
        );
    }

    @Override
    public SysUser getByUsername(String username) {
        switch (username) {
            case "abc": {
                return userAbc();
            }
            case "123": {
                return user123();
            }
            case "michael": {
                return userMichael();
            }
            default:
                return null;
        }
    }
}
